<?php
include_once 'BaseDAO.php';
//include_once '../util/plog/classes/plog.php';

class SupplierBrandDAO extends BaseDAO {
	
	public function __construct() {
		parent::__construct ();
//		$this->log = Plog::factory ( __FILE__ );
	}
	
	public function queryByCm_id($cm_id) {
		$sql = "select * from supplier_brand where cm_id=$cm_id";
		//		echo  $sql;
		$result = @mysql_query ( $sql );
		return $this->toArray ( $result );
	}
	
	public function queryByAll() {
		$sql = "select * from supplier_brand order by sb_id desc limit 6";
		//		echo  $sql;
		$result = @mysql_query ( $sql );
		return $this->toArray ( $result );
	}
	
	public function queryHasProductBrands(){
		$sql = "select * from supplier_brand  where sb_id in ( select sb_id from product where pic is not null)";
		$result = @mysql_query ( $sql );
		return $this->toArray ( $result );
	}
	
	public function queryByProdSubType($pt_id){
		$sql = "SELECT distinct sb.* FROM supplier_brand sb, product p, prod_type pt, prod_sub_type pst where sb.sb_id=p.sb_id and p.sort=pst.pst_id and pst.type=pt.pt_id and pt.pt_id=$pt_id";
		$result = @mysql_query ( $sql );
		return $this->toArray ( $result );
	}
}
?>